/*    */ package com.wzh.action.front.book;
/*    */ 
/*    */ import com.opensymphony.xwork2.ActionContext;
/*    */ import com.wzh.action.front.CommonAction;
/*    */ import com.wzh.bean.book.BookChapter;
/*    */ import com.wzh.bean.book.BookInfo;
/*    */ import com.wzh.constant.CommonConstant;
/*    */ import com.wzh.service.bookinfo.BookInfoService;
/*    */ import com.wzh.service.bookinfo.chapter.BookChapterService;
/*    */ import com.wzh.utils.CommonUtil;
/*    */ import com.wzh.utils.WebTool;
/*    */ import javax.annotation.Resource;
/*    */ import javax.servlet.ServletContext;
/*    */ import org.apache.struts2.ServletActionContext;
/*    */ 
/*    */ public class ChapterAction extends CommonAction
/*    */ {
/*    */   private static final long serialVersionUID = 1L;
/*    */ 
/*    */   @Resource
/*    */   private BookChapterService chapterService;
/*    */ 
/*    */   @Resource
/*    */   private BookInfoService bookService;
/*    */   private Integer chapterid;
/*    */ 
/*    */   public Integer getChapterid()
/*    */   {
/* 29 */     return this.chapterid;
/*    */   }
/*    */   public void setChapterid(Integer chapterid) {
/* 32 */     this.chapterid = chapterid;
/*    */   }
/*    */ 
/*    */   public String getChapterById()
/*    */   {
/* 40 */     BookChapter chapter = (BookChapter)this.chapterService.find(this.chapterid);
/* 41 */     BookInfo bookInfo = (BookInfo)this.bookService.find(chapter.getBookid());
/*    */ 
/* 43 */     String filepath = ServletActionContext.getServletContext().getRealPath(CommonConstant.TXTPATH) + 
/* 44 */       "/" + chapter.getBookid() + "/" + this.chapterid + ".txt";
/*    */ 
/* 46 */     chapter.setContent(CommonUtil.readFileContent(filepath));
/* 47 */     this.bookService.setInfo(bookInfo, true, false);
/* 48 */     this.chapterService.setPreAndPostUrl(chapter);
/* 49 */     ActionContext.getContext().put("bookInfo", bookInfo);
/* 50 */     ActionContext.getContext().put("chapter", chapter);
/*    */ 
/* 52 */     if (WebTool.isMHost(ServletActionContext.getRequest()))
/*    */     {
/* 54 */       this.template += "/mobile";
/*    */     }
/* 56 */     return "chapter";
/*    */   }
/*    */ }

/* Location:           C:\work\apache-tomcat-7.0.55\webapps\ROOT\WEB-INF\classes\
 * Qualified Name:     com.wzh.action.front.book.ChapterAction
 * JD-Core Version:    0.6.1
 */